home *** CD-ROM | disk | FTP | other *** search
/ 8bitfiles.net/archives / archives.tar / archives / compuserve-file-archive / 22 Graphics & Utilities / GIF01.THD < prev    next >
Encoding:
Text File  |  2019-04-13  |  5.8 KB  |  128 lines

  1.  
  2.  
  3. #: 22725 S10/Graphics Util & GIF
  4.     18-Apr-90  13:17:56
  5. Sb: #array .GIF?
  6. Fm: John Ritter 76334,1433
  7. To: [F] Todd Heimarck/Sysop 76703,3051 (X)
  8.  
  9. OK... so here I am in the message board. What I was thinking is using 4096
  10. bytes as my string table. The first 'n' are for the initial color table, byte
  11. 'n' is the clear code, byte 'n+1' is the EOI, and then the rest are free for
  12. the decompression, as follows: The first character received goes in a temp
  13. byte: <old>, and is placed in temp storage. The next character received either
  14. will or won't be in the code table. If not, then <old> replaces it, and the
  15. output code is:   <old> + the byte values of the memory array (the 4096 bytes)
  16. up to the current limit of the string table. Then you get the next code,
  17. compare it, etc. If it does appear in the string table, then make your pointer
  18. equal to that value (say 'n + m') then output the string byte by byte from
  19. <old> + <n+2> to <n+m>.
  20.      I may be missing something crucial there, but it seems fairly straight
  21. forward. Now the next bit is creating the bit patterns for the codestream
  22. (grabbing the GIF encoded data) from a stream that may be 4 bits long up to 12
  23. bits/character, all on an 8-bit machine.
  24.  
  25.  
  26.  
  27.  
  28. #: 22736 S10/Graphics Util & GIF
  29.     20-Apr-90  04:01:44
  30. Sb: #22725-array .GIF?
  31. Fm: Todd Heimarck/Sysop 76703,3051
  32. To: John Ritter 76334,1433 (X)
  33.  
  34. John:
  35.    It _is_ pretty straightforward and the actual coding shouldn't be tough,
  36. except in two areas (both of which are inherent limitations of the 64).  The
  37. first is memory.
  38.    Let's say your 16 colors are called "a" through "p".  And let's say code 500
  39. represents the string of pixels "abcacac."  How do you represent that in
  40. memory?  Do you use up seven bytes?  No.  Consider this: there are potentially
  41. 4096 codes and in the worst possible case, code 18 has two colors, 19 has 3, 20
  42. has 4, and so on, up to code 4095 has 4079 pixels.  If you add that up, you'd
  43. need approximately 8 million bytes of memory to hold the possibilities.
  44.    But I've figured out a tree that uses only five bytes per code (5 * 4096 is
  45. only about 20K, which fits easily into a 64 or 128).  You need one byte for the
  46. color, two bytes for a pointer to the oldest child, and two bytes for a pointer
  47. to the next sibling.  (This is for encoding, BTW, where you need to build the
  48. table).  For decoding, you need one byte for the color, and two bytes for a
  49. pointer back to the immediate parent.  I'd also add two bytes for a temporary
  50. pointer forward.
  51.    So when you get code 500, you check #500 and its color is "c" (the last byte
  52. in "abcacac").  Its parent node is, say #480, so you move back and get the
  53. color "a" (second-to-the-last-byte) and insert the temporary pointer (at 480)
  54. to point to 500.  Then you work backwards until you have one of the original
  55. colors (number 0-15), which is "a".  Then you follow the breadcrumbs back to
  56. where you started and output a, b, c, etc. to the screen.  Then you have to do
  57. two things: take the first byte (the first "a"), which has to be the final
  58. color of the most recent string (maybe #779, which doesn't know its color byte
  59. yet).  Then you add the next code (#780, which links back to code #500, its
  60. parent, but 780 doesn't know its color yet).
  61.    <<continued in next message>>
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68. #: 22737 S10/Graphics Util & GIF
  69.     20-Apr-90  04:02:02
  70. Sb: #22725-array .GIF?
  71. Fm: Todd Heimarck/Sysop 76703,3051
  72. To: John Ritter 76334,1433 (X)
  73.  
  74. <<continued>>
  75.    The second problem is deciding which colors are displayed.  I assume you're
  76. writing a decoder for the 64's hi-res screen (but the problems are similar on
  77. the 128's 80-column screen).
  78.    Let's say you're decoding a 256-color picture that originated on an IBM with
  79. a VGA screen.  You get the RGB values up front, and at that time you should
  80. translate each IBM color into one of the 16 available colors on the 64, which
  81. is no problem (I can go into more detail if you want).  That way, when you get
  82. color 251, maybe it translates into the 64's cyan (or whatever).
  83.    Here's the problem: On the 64's hi-res screen, each 8x8 section can only
  84. contain two colors -- a foreground and a background.  But in the IBM picture,
  85. there might be 64 different colors.  How do you decide which two colors to
  86. display?  One solution is to let them vote.  Whichever colors are most popular
  87. are the ones you use.  That works on regular (non-interleaved) pictures, but
  88. you may run out of memory with interleaved pictures, which provide line 0, line
  89. 8, line 16, etc., then go back and fill in the blanks.
  90.    So, good luck, John.  If you're confused about any of the GIF details, give
  91. me a holler.
  92.    ToddH
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100. #: 22751 S10/Graphics Util & GIF
  101.     21-Apr-90  08:54:45
  102. Sb: GIF again
  103. Fm: John Ritter 76334,1433
  104. To: [F] Todd Heimarck 76703,3051
  105.  
  106. I know about the color 8x8 matrices and it seems like GIFFY.BIN uses an update
  107. algorythym (sp?) that merely changes the colors dependant on what colors are
  108. present. It seems that the first color from the first value of the code table
  109. (the first root) is assigned as a 'background color' and then all the others
  110. fight it out: the last color updated in the particular matrix becomes the final
  111. color of that matrix. The only problem I can see with this on the 80 col screen
  112. is that without the 128D conversion, you're limited tmonochrome if you want
  113. bit-map. Of course, it doesn't mean black/white, but say the third color = red.
  114. Sometimes that will be light (as in a black background) or dark (as in a cyan
  115. background). With all the finely tuned images presented in a digitized picture,
  116. which is bit-mapped images strong point, the question becomes 'How do we
  117. differentiate between light/dark'. But even this is e
  118. .. Just look at all the greyscales being done. I've already worked through a
  119. matrix for color assignments based upon RGBI, so that should prove to be no
  120. hassle. Skol! and I'll be back on later to let you know what's up!
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.